#include "Includes.h"
#include "HL2Interface.h"

bool CheckKeys()
{
	if (GetAsyncKeyState(VK_INSERT) & (1<<15))
	{
		g_pConfigManager.Execute1();
		return true;
	}
	else if (GetAsyncKeyState(VK_DELETE) & (1<<15))
	{
		g_pConfigManager.Execute2();
		return true;
	}
	else if (GetAsyncKeyState(VK_HOME) & (1<<15))
	{
		g_pConfigManager.Execute3();
		return true;
	}
	else if (GetAsyncKeyState(VK_END) & (1<<15))
	{
		g_pConfigManager.Execute4();
		return true;
	}
	else if (GetAsyncKeyState(VK_PRIOR) & (1<<15))
	{
		g_pConfigManager.Execute5();
		return true;
	}
	else if (GetAsyncKeyState(VK_NEXT) & (1<<15))
	{
		g_pConfigManager.Execute6();
		return true;
	}
	return false;
}

void HackThread()
{
	g_pInterfaces.Start();
	//////////////////////////////////////////////////////////////////////////
	while (true)
	{
		if (CheckKeys())
		{
			Sleep(250);
		}
		Sleep(10);
	}
	//////////////////////////////////////////////////////////////////////////
	return;
}

BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD dwReason, LPCVOID lpReserved)
{
	switch(dwReason)
	{
	case DLL_PROCESS_ATTACH:
		g_pInterfaces.hModuleBase = hInst;
		CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)HackThread, 0, 0, 0);
		break;
	case DLL_PROCESS_DETACH:
		break;
	}
	return TRUE;
}
